home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!hpl3sn03.cern.ch
- From: Dan Pop <danpop@mail.cern.ch>
- Newsgroups: comp.lang.c
- Subject: Re: C type question
- Date: Mon, 5 Feb 1996 21:38:13 +0100
- Organization: CERN European Lab for Particle Physics
- Message-ID: <9602052038.AA06872@dxmint.cern.ch>
- References: <Pine.SUN.3.91.960202131027.20090A-100000@sun19.cs.cuhk.hk> <31165E58.104B@imsisoft.com>
- X-NNTP-Posting-Host: hpl3sn03.cern.ch
- X-Newsreader: NN version 6.5.0 #7 (NOV)
- X-Mail2News-Path: dxmint.cern.ch!hpl3sn03.cern.ch
-
- Victor Bazarov <vbazarov@imsisoft.com> writes:
-
- >The problem is that some compilers expect "%le" for double values.
- >Their printf accepts %e, %f, or %g as formats for float values, not
- >double. So try %le.
-
- Please read the FAQ before posting such nonsense.
-
- 1. printf _cannot_ display float values at all. Guess why.
-
- 2. %e, %f and %g are all used for double values.
-
- 3. %le in a printf format is meaningless and it invokes undefined behaviour.
- Most vendors simply ignore the 'l' and treat %le as %e, but this is not
- a valid reason for recommending its usage.
-
- Here's the relevant paragraph from the C standard:
-
- * An optional h specifying that a following d , i , o , u , x , or X
- conversion specifier applies to a short int or unsigned short int
- argument (the argument will have been promoted according to the
- integral promotions, and its value shall be converted to short int or
- unsigned short int before printing); an optional h specifying that a
- following n conversion specifier applies to a pointer to a short int
- argument; an optional l (ell) specifying that a following d , i , o ,
- u , x , or X conversion specifier applies to a long int or unsigned
- long int argument; an optional l specifying that a following n
- conversion specifier applies to a pointer to a long int argument; or
- an optional L specifying that a following e , E , f , g , or G
- conversion specifier applies to a long double argument. If an h , l ,
- ^^^^^^^^^^^^^
- or L appears with any other conversion specifier, the behavior is
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- undefined.
- ^^^^^^^^^^
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-